package ua.vip.easyportfolio.service;

import com.google.gdata.data.photos.AlbumEntry;
import com.google.gdata.util.ServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import ua.vip.easyportfolio.dao.IPhotoDao;

import java.io.IOException;
import java.util.*;

/**
 * User: viktorp
 * Date: Mar 8, 2010
 * Time: 6:42:24 PM
 */
public class PhotoService implements IPhotoService {
    private static final Logger LOGGER = LoggerFactory.getLogger(PhotoService.class);
    private IPhotoDao photoDao;

    @Autowired
    public void setPhotoDao(IPhotoDao photoDao) {
        this.photoDao = photoDao;
    }

    @Override
    public Collection<AlbumEntry> getAlbums(String userName) {
        LOGGER.debug("Locating picasa albums");
        try {
            return photoDao.getAlbums(userName);
        } catch (IOException e) {
            LOGGER.error("Error", e);
        } catch (ServiceException e) {
            LOGGER.error("Error", e);
        }
        return Collections.EMPTY_LIST;
    }

    @Override
    public Collection<AlbumEntry> getPortfolioAlbums(String login) {
        return photoDao.getPortfolioAlbums(login);
    }

}
